package yang.VirtualMachine.chapter9.classStruct.constantPool;

import java.io.IOException;
import java.io.InputStream;

import yang.VirtualMachine.chapter9.ClassBean;
import yang.VirtualMachine.chapter9.ClassUtil;

/**
 * JDK1.7加入
 * u1 tag;u2 bootstrap_method_attr_index;u2 name_and_type_index;
 * @author xinxin
 */
public class Con_InvokeDynamicProcesser implements PoolValue {
	/** 指向引导方法表，即定位一个引导方法 */
	private int bootstrapMethodAttrIndex;
	
	private int nameAndTypeIndex;

	@Override
	public void process(InputStream input) throws IOException {
		bootstrapMethodAttrIndex = (int) ClassUtil.getNumByStream(input, 2);
		nameAndTypeIndex = (int) ClassUtil.getNumByStream(input, 2);
	}

	@Override
	public String getValue() {
		// TODO
		PoolValue nameValue = ClassBean.getInstance().constantPool[bootstrapMethodAttrIndex];
		PoolValue descValue = ClassBean.getInstance().constantPool[nameAndTypeIndex];
		return descValue.getValue() + ":" + nameValue.getValue();
	}

}
